
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:qianyi/controller/homeTabController.dart';
import 'package:qianyi/entity/home/trendVo.dart';
import 'package:qianyi/network/http_entity.dart';
import 'package:shared_preferences/shared_preferences.dart';

import '../../entity/home/AlbumEntity.dart';
import '../../entity/home/album_detail_list_entity.dart';
import '../../entity/profile/my_user_info_entity.dart';
import '../../network/base_entity.dart';
import '../../network/http_config.dart';
import '../../network/http_manager.dart';
import '../../ui/widget/custom_refresh_mixin.dart';
import '../../utils/navigator_util.dart';


class AlbumDetailListModel extends ChangeNotifier with CustomRefreshMixin {

  TabController? tabController;

  HomeTabController homeTabController = Get.find();
  AlbumEntity? albumEntity;

  @override
  Future<List> requestList(int page) async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    Map<String,dynamic> userInfo = jsonDecode(prefs.getString("userInfo")!);
    Map<String,String> params1 = {
      "id":homeTabController.albumDetailId
    };
    HttpEntity httpEntity1 = await HttpManager.getInstance().request(url: '/platform/album/getAlbum',params: params1,method: Method.get) as HttpEntity;
    albumEntity = AlbumEntity.fromJson(httpEntity1.getOriData()['data']);



    Map<String, dynamic> params = {};
    params["albumId"] = homeTabController.albumDetailId;
    params["type"] = 1;
    IBaseEntity? result = await HttpManager.getInstance().request(url: "/platform/imgDetail/getAllImgByAlbum/${page}/10",method: Method.get, params: params);
    HttpEntity httpEntity = result as HttpEntity;
    AlbumDetailEntityList trendEntityList = AlbumDetailEntityList.fromJson(httpEntity.oriData["data"]["records"]);




    notifyListeners();

    return trendEntityList.datas!;
  }

  }
